module.exports = class extends think.Service {



    async getCPWorksCountByWorksGuid(workGuid){
        this.cpStepsInstance=think.model('v2/competitionSteps');
        this.wsNoInstance=think.model('v2/workSno');
        this._worksCount=0;

        /*
           算法:
           1,首先查出该比赛里有哪些步骤
           2,计算每个步骤里有多少作品并相加
        */

        let cpStepsData=await this.cpStepsInstance.getCPStepsByCPGuid(workGuid);
        for(let index in cpStepsData){
            let stepGuid=cpStepsData[index]['PK_CompetitionStepsGuid'];
            let wkc=await this.wsNoInstance.getWorksCountByWorkStepsGuid(stepGuid);
            this._worksCount+=wkc;
        }
        return this._worksCount;
    }

}